package ua.edu.nuos.jeetraining2012.cms.ui.events;

import com.vaadin.ui.MenuBar;
import ua.edu.nuos.jeetraining2012.cms.util.LocaleWrapper;

import static com.vaadin.ui.UI.getCurrent;

/**
 * Created with IntelliJ IDEA.
 * User: mody
 * Date: 05.06.13
 * Time: 19:06
 * To change this template use File | Settings | File Templates.
 */
public class LanguageMenuBarCommand {


    private String language;
    private String country;
    private MenuBar.Command command;

    public LanguageMenuBarCommand(String language, String country) {
        this.language = language;
        this.country = country;

    }


    public MenuBar.Command menuSelected() {

        command = new MenuBar.Command() {
            @Override
            public void menuSelected(MenuBar.MenuItem menuItem) {
                LocaleWrapper.setLocale(language, country);
                getCurrent().getPage().setLocation("");
            }
        };

        return command;
    }
}
